project/ugps.git
9 months agougps: add quality measurement parameters master
Zbyněk Kocur [Wed, 14 Feb 2024 09:25:23 +0000 (10:25 +0100)]
ugps: add quality measurement parameters

The current version of ugps does not report any quality parameters for
GPS receiver fixation. Considering the positioning error, which can be
up to hundreds of meters, it is helpful to know how accurately the GPS
determines the position.

This PR supports determining the number of satellites and the HDOP
(Horizontal Dilution of Precision) parameter to address this.  The GPGGA
sentence is already parsed in the code, so it just extends the amount of
data it reads.

Fixes: #2 (ugps miss GPS quality parameters)
Signed-off-by: Zbynek Kocur <zbynek.kocur@fel.cvut.cz>
Signed-off-by: Petr Štetiar <ynezz@true.cz> [whitespace fixes, long line wrap]
22 months agomain.c: -S does not take any options
John Crispin [Fri, 27 Jan 2023 12:07:25 +0000 (13:07 +0100)]
main.c: -S does not take any options

Fixes: fb87d0fd051b (ugps: add baud rate command line option)
Signed-off-by: John Crispin <john@phrozen.org>
2 years agougps: add baud rate command line option
Wojciech Jowsa [Sun, 16 Jan 2022 20:28:36 +0000 (21:28 +0100)]
ugps: add baud rate command line option

currently, gps device baud rate is hardcoded so
ugps might not work with devices
that baud rate is configured to be different than 4800.

Signed-off-by: Wojciech Jowsa <wojciech.jowsa@gmail.com>
3 years agoadd support for multi GNSS solutions
John Crispin [Sat, 19 Jun 2021 13:46:02 +0000 (15:46 +0200)]
add support for multi GNSS solutions

Signed-off-by: John Crispin <john@phrozen.org>
3 years agoubus: display only available information
Daniel Golle [Mon, 7 Jun 2021 21:44:52 +0000 (22:44 +0100)]
ubus: display only available information

GPS receivers may not provide all possible data, some take more time
and some are irrelevant for some applications and are never sent by
some GPS receivers (eg. equipment found in maritime context doesn't
report elevation). Only populate attributes for which data is actually
available.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
3 years agonmea: parse $GPGLL sentences for position
Daniel Golle [Mon, 7 Jun 2021 21:14:30 +0000 (22:14 +0100)]
nmea: parse $GPGLL sentences for position

Some GPS receivers do not send $GPGGA sentence. Parse latitude and
longitude also from $GPGLL sentences.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
3 years agonmea: parse $GPZDA sentences for date/time
Daniel Golle [Mon, 7 Jun 2021 19:50:26 +0000 (21:50 +0200)]
nmea: parse $GPZDA sentences for date/time

Some GPS receivers only send $GPZDA sentence for date/time. Parse it
and refactor NMEA-0138 code to avoid code duplication.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
4 years agougps: fix 64-bit time_t
Rosen Penev [Tue, 21 Jul 2020 22:50:37 +0000 (15:50 -0700)]
ugps: fix 64-bit time_t

The abs function takes a 32-bit int, which can cause truncation. Fixes
compilation error:

error: absolute value function 'abs' given an argu>
if ((sec < 0) || (abs(cur.tv_sec - tv.tv_sec) > MAX_TIME_OFFSET)) {

Signed-off-by: Rosen Penev <rosenp@gmail.com>
4 years agonmea: make sure date is valid
Daniel Golle [Tue, 26 May 2020 13:29:07 +0000 (14:29 +0100)]
nmea: make sure date is valid

GPS time without date was previously used to set system date:
Tue Oct 10 11:48:21 2000 user.info kernel: [  108.786639] ugps: system time differs from GPS time by more than 5 seconds. Using 2000-10-10T10:48:21 UTC as the new time
Tue Oct 10 11:49:27 2000 user.info kernel: [  174.794699] ugps: system time differs from GPS time by more than 5 seconds. Using 2020-05-26T10:49:27 UTC as the new time

Fix this by ignoring incomplete dates and wait for complete time
information before adjusting system date/time.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
4 years agonmea: fix time comparision
Daniel Golle [Wed, 29 Apr 2020 17:14:16 +0000 (18:14 +0100)]
nmea: fix time comparision

Code introduced by commit b88037b ("check timegm return code") compares
GPS-time with tv_sec of freshly zero-initialized struct timeval tv.
Compare with current time instead.

Fixes: b88037b ("check timegm return code")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
5 years agougps: Fix compilation under 64-bit
Rosen Penev [Sun, 23 Jun 2019 21:52:10 +0000 (14:52 -0700)]
ugps: Fix compilation under 64-bit

strlen returns size_t, not int.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
5 years agoFix build error caused by enabled extra compiler warnings
Petr Štetiar [Tue, 25 Jun 2019 14:43:18 +0000 (16:43 +0200)]
Fix build error caused by enabled extra compiler warnings

 nmea.c:257:16: error: comparison between signed and
     unsigned integer expressions [-Werror=sign-compare]

Signed-off-by: Petr Štetiar <ynezz@true.cz>
5 years agoEnable extra compiler warnings
Petr Štetiar [Tue, 25 Jun 2019 14:39:48 +0000 (16:39 +0200)]
Enable extra compiler warnings

Signed-off-by: Petr Štetiar <ynezz@true.cz>
6 years agonmea.c: set _BSD_SOURCE to have timegm() & stime() on musl
Alexander Couzens [Sun, 11 Nov 2018 01:19:32 +0000 (02:19 +0100)]
nmea.c: set _BSD_SOURCE to have timegm() & stime() on musl

musl doesn't know _DEFAULT_SOURCE which is used by glibc >= 2.19
to enable timegm() and stime().

Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
6 years agocheck timegm return code
John Crispin [Thu, 12 Jul 2018 08:05:17 +0000 (10:05 +0200)]
check timegm return code

Signed-off-by: John Crispin <john@phrozen.org>
6 years agonmea.c: Add null byte to nmea fields
Alexander Couzens [Fri, 29 Jun 2018 21:19:11 +0000 (23:19 +0200)]
nmea.c: Add null byte to nmea fields

Either the main.c treat them as non-null terminated strings or
nmea adds a null byte to the fields.

Found-by: Coverity
Fixes CID 1431321 1431098

6 years agoremove deprication warning
John Crispin [Mon, 12 Feb 2018 14:40:37 +0000 (15:40 +0100)]
remove deprication warning

In file included from /usr/include/time.h:27:0,
from /src/projects/ugps/nmea.c:21:
/usr/include/features.h:148:3: error: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Werror=cpp]

Signed-off-by: John Crispin <john@phrozen.org>
6 years agougps: Only convert lat and lon to negative after parsing
Giovani Espindola [Fri, 20 Oct 2017 12:19:02 +0000 (10:19 -0200)]
ugps: Only convert lat and lon to negative after parsing

This is a bugfix for package ugps.

Current code parses following GPRMC

$GPRMC,185834.0,A,2335.766399,S,04635.923564,W,0.0,,191017,0.0,E,A*20

as

position: -22.929440 -45.932056

with this fix it's being parsed correctly as

position: -23.596106 -46.598721

Signed-off-by: Giovani Milanez Espindola <gespindola@advantech-bb.com>
>From 092b311a3c8911ce9da3f913787b77397e88b4a8 Mon Sep 17 00:00:00 2001
From: Giovani Espindola <gespindola@advantech-bb.com>
Date: Thu, 19 Oct 2017 15:54:05 -0200
Subject: [PATCH] Only convert lat and lon to negative after parsing

7 years agolink libm to fix build error
Felix Fietkau [Sat, 11 Feb 2017 16:51:50 +0000 (17:51 +0100)]
link libm to fix build error

Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 years agoSwitched from strptime to sscanf, added command line switch to set system clock and...
Thomas Hooge [Tue, 18 Oct 2016 07:06:38 +0000 (09:06 +0200)]
Switched from strptime to sscanf, added command line switch to set system clock and fixed typo

Signed-off-by: Thomas Hogge <thomas@hoogi.de>
8 years agougps: Simplify and fix position computation from GPRMC sentence
Petr Štetiar [Wed, 31 Aug 2016 07:15:44 +0000 (09:15 +0200)]
ugps: Simplify and fix position computation from GPRMC sentence

Current code parses following GPRMC

  $GPRMC,071305.0,A,5207.76855,N,02104.022546,E,0.0,,270816,0.0,E,A*18

as

  position: 52.117947 21.67042

with this fix it's being parsed correctly as

  position: 52.129475 21.067041

Fixes https://github.com/lede-project/source/issues/279

Signed-off-by: Petr Štetiar <ynezz@true.cz>
Tested-by: Cezary Jackiewicz <cezary@eko.one.pl>
8 years agofix ms->deg conversion
John Crispin [Thu, 18 Aug 2016 11:18:23 +0000 (13:18 +0200)]
fix ms->deg conversion

Signed-off-by: John Crispin <john@phrozen.org>
8 years agofix reading of speed
John Crispin [Thu, 18 Aug 2016 08:46:16 +0000 (10:46 +0200)]
fix reading of speed

Signed-off-by: John Crispin <john@phrozen.org>
8 years agoAllow bigger lat/lng numbers in RMC message
Petr Štetiar [Wed, 27 Jul 2016 12:45:54 +0000 (14:45 +0200)]
Allow bigger lat/lng numbers in RMC message

It works now with following message:

  $GPRMC,122536.0,A,4350.237769,N,01826.423315

Signed-off-by: Petr Štetiar <ynezz@true.cz>
8 years agoShow more useful error message if we can't open GPS device
Petr Štetiar [Wed, 27 Jul 2016 12:45:53 +0000 (14:45 +0200)]
Show more useful error message if we can't open GPS device

Signed-off-by: Petr Štetiar <ynezz@true.cz>
8 years agoFix typo in error message
Petr Štetiar [Wed, 27 Jul 2016 12:45:52 +0000 (14:45 +0200)]
Fix typo in error message

Signed-off-by: Petr Štetiar <ynezz@true.cz>
8 years agoUse strsep for NMEA message tokenization
Petr Štetiar [Wed, 27 Jul 2016 12:45:51 +0000 (14:45 +0200)]
Use strsep for NMEA message tokenization

strtok doesn't parse correctly following message:

  $GPGSA,A,1,,,,,,,,,,,,,,,*1E

Resulting in "datagram has wrong parameter count".

Signed-off-by: Petr Štetiar <ynezz@true.cz>
8 years agoBail out if we can't find GPS device
Petr Štetiar [Wed, 27 Jul 2016 12:45:50 +0000 (14:45 +0200)]
Bail out if we can't find GPS device

Signed-off-by: Petr Štetiar <ynezz@true.cz>
8 years agoSwitch to ulog for logging and add few commandline params
Petr Štetiar [Wed, 27 Jul 2016 12:45:49 +0000 (14:45 +0200)]
Switch to ulog for logging and add few commandline params

Signed-off-by: Petr Štetiar <ynezz@true.cz>
8 years agocmake: Add proper library and include files search logic for dependecies
Petr Štetiar [Wed, 27 Jul 2016 12:45:48 +0000 (14:45 +0200)]
cmake: Add proper library and include files search logic for dependecies

Signed-off-by: Petr Štetiar <ynezz@true.cz>
9 years agolat/lng format when printing is incorrect
John Crispin [Tue, 11 Aug 2015 14:53:34 +0000 (16:53 +0200)]
lat/lng format when printing is incorrect

Signed-off-by: Maurice-Jörg Nießen <post@mjniessen.com>
9 years agotypo fix
John Crispin [Tue, 11 Aug 2015 14:51:32 +0000 (16:51 +0200)]
typo fix

Signed-off-by: Maurice-Jörg Nießen <post@mjniessen.com>
10 years agoImport
John Crispin [Tue, 29 Jul 2014 04:39:38 +0000 (05:39 +0100)]
Import